Class Wrangler is Metrowerks' utility program for working with Java Archive (jar) files on the Mac OS. It allows you to add or remove files, as well as copy files from one zip/Jar file to another. Class Wrangler has other useful features as well.
NOTE:
Class Wrangler is not a general purpose utility for compressed zip files. It will only handle zip archives that are all contained in one file (no disk-spanning files). If the zip archive is compressed, the deflate algorithm must be the one used in JDK 1.1 JAR files. Class Wrangler cannot handle encrypted files.
This chapter explains the Class Wrangler interface, and how you can use it to get your work done. The sections in this chapter are:
Class Wrangler uses a single window to display each package and class file stored in a zip archive or Jar file, as shown in Figure 8.1.
Figure 8.1 The Class Wrangler Window
You can use the button bar to add, extract, delete, and get information on files. Table 8.1 describes each button.
Table 8.1 Class Wrangler button bar
The diamond icon at the top right is empty if the zip archive has not changed since the last time it was saved, and contains a red check mark if the file has been changed.
Each package lists all the files and sub-packages it contains. To show or hide the contents of a package, click the disclosure triangle.
To the right of each file is its size in bytes. If a file is in italics, it has recently been added to the archive and has not been saved to disk yet. To save it, choose File > Save
.
You can choose Edit > Copy
to copy the names of the selected files and packages to the Clipboard. When you copy a file, its fully qualified name is placed in the Clipboard. For example, if you copy AudioClip.class, this text is placed in the Clipboard:
java.applet.AudioClip
If you hold down the Option key while copying a class, an import
statement for the selected class is placed in the clipboard:
import java.applet.AudioClip;
If you copy a package, its name, the names of its subpackages, and the names of its class files are placed in the Clipboard. If you hold down the Option key while copying, an import
statement for the subpackages, and the class files are placed in the Clipboard.
Typing a full or partial file or package name selects the closest matching item in the Class Wrangler window. This is called "type ahead selection" and allows you to move around the archive quickly when you know the file or package you are looking for.
See also
"Use full package name for type ahead."
This section explores how you can get work done using Class Wrangler. To avoid confusion, these topics refer to class files, zip archives, and Jar files (Java Archive files) consistently. Keep in mind that each is really just a kind of file.
Zip archives and Jar files are used interchangeably. The main difference is a Jar file can have manifest files, whereas Zip archives do not.
The topics in this section are:
There are two ways to open a zip archive:
Class Wrangler opens the file and displays its contents in a window.
At the bottom of the Open dialog, there are three check boxes that let you choose which files the dialog displays. When no option is checked, the dialog displays only files whose Macintosh file types are for zip or class files. When the Filter using file extension option is on, the dialog also shows any file whose name ends in .zip
or .class
. When the Filter using file contents
option is on, Class Wrangler examines the internal contents of each file and displays any file that it determines to be a zip or class file. This option is the most accurate, but takes the most amount of time. When the Show all files
option is checked, Class Wrangler displays all files in a directory. This option overrides the other two, even if the other two are checked.
You can set these options generally for the program as well. See "File Filtering Settings."
There are three ways to create a zip archive with Class Wrangler. To create an empty zip archive, choose File > New
. To create a zip archive that contains one class file, choose File > Open
, and select the class file. Class Wrangler displays a new window that contains that file.
To create a zip archive for several class files, follow these steps:
1. Make sure that Class Wrangler is not running or that there are no open windows in Class Wrangler.
2. Drag and drop the class files onto the Class Wrangler icon.
Class Wrangler creates a window that contains those class files.
NOTE:
If you drag class files onto the Class Wrangler icon while there is an open archive, the class files are added to the archive displayed in the frontmost Class Wrangler window.
Class Wrangler gives you three ways to add \xde les to an archive.
If you try to add a class file that is already in the zip archive, Class Wrangler displays an alert asking you whether you want to overwrite the existing file.
After you add class files, their names appear in italics in the window to show the new files have not been saved to the zip archive on disk. To save the new files to disk, choose File > Save
.
If you use the Add Files
command or button, Class Wrangler displays a dialog like the one shown in Figure 8.2.
The top list is part of a standard file dialog and displays the contents of a folder. The bottom list contains all the files that will be added to the zip archive when you click the Done
button. To choose a file to add, select it in the top list and click Add
. To add all the files in the top list, click Add All
. To remove a file from the bottom list, select it and click Remove
. To remove all the files from the bottom list, click Remove All
.
Figure 8.2 The Add Files dialog
The three check boxes at the bottom of the dialog let you choose which files the dialog displays. When no option is checked, the dialog displays only files whose Macintosh file types are for zip or class files. When the Filter using file extension option is on, the dialog also shows any file whose name ends in .zip
, .jar
, or .class
. When the Filter using file contents
option is on, Class Wrangler examines the internal contents of each file and displays any file that it determines to be a zip or class file. This option is the most accurate, but takes the most amount of time. When the Show all files
option is checked, Class Wrangler displays all files in a directory. This option overrides the other two, even if the other two are checked.
You can set these options generally for the program as well. See "File Filtering Settings."
The Package > Add Directory
command allows you to add a package to the frontmost archive as shown in Figure 8.3. You must type the full path name. The directory is created in the archive.
Figure 8.3 Add Directory dialog
Class Wrangler gives you two ways to extract class files from a zip archive. The class files remain in the zip archive after they are extracted. The process of extraction does not remove the class file from the zip archive.
TIP:
If you do not want the folder hierarchy, hold down the Option key while dragging.
When Class Wrangler extracts a file, it places the file in a folder hierarchy that matches the file's package hierarchy. For example, if the file is in the hierarchy java.util
, Class Wrangler creates the folder java
at the location you selected, creates the folder util
inside java
, and places the file in util
.
To delete a class file from a zip archive, select the file and do one of the following:
Class Wrangler indicates the file is flagged for deletion by displaying the file name in italics. You must choose File > Save
to completely remove the files.
You can see information on any class file in a zip archive. Just select the class file and choose Package > Get Info
or click the Information button in the Class Wrangler window. Class Wrangler displays a window of information on the public class in the class file, including information on its fields, methods, interfaces, and superclass, as shown Figure 8.4.
Information windows are associated with an open archive document. If the associated archive document is closed, all of its information windows are closed.
Figure 8.4 The Class Wrangler Get Information window
Click the sub-pane zoom box control to expand the pane to fill the entire information window, or shrink the pane to see all sub-panes.
You can move a file from one archive to another. Open both archives in Class Wrangler, and drag the files from one window to another. Class Wrangler copies the files from the source archive into the destination archive. The files are not removed from the source archive.
Class Wrangler also allows you to edit some manifest data for the currently selected item in the active archive. Choose Package > Edit Manifest
to edit the manifest data for the currently selected item.
Figure 8.5 Edit Manifest dialog
Manifest data is displayed for the item (Figure 8.5) for you to verify. This data reflects the state of the item in memory, not on disk. So the JavaBean item will display the state of that item as it would currently be saved to disk, not as it was originally.
Certain items, such as the name, SHA
, and MD5
hash codes, cannot be modified. The Depends
list is a list of items. Any text can be dragged to this pane in order to add it to the list. The Other
list holds all manifest tags that are not yet specifically parsed by Class Wrangler. These could include new tags from Sun or special user-defined tags.
See also
Sun's documentation for the complete explanation of manifest tags and the manifest file format.
This section discusses how to control the way Class Wrangler works for you. As with most programs, Class Wrangler has preferences you can set to control its operation. When you choose Edit > Preferences
, Class Wrangler displays a Preferences dialog box as shown in Figure 8.6.
Figure 8.6 The Class Wrangler Preferences dialog
Click the Factory
button to restore the settings to program defaults.
The effect of these options is described in the following topics:
The first group of preference settings control how you interact with Class Wrangler.
Filename truncation
The Filename truncation
pop-up menu operates similar to the same menu in the
Java Target
panel in the CodeWarrior IDE. On the Mac OS, file names cannot be greater than 31 characters long. If you extract a class file that is greater than 31 characters, Class Wrangler uses this setting to determine where the extra characters will be eliminated from. Options are: Front
, Middle
, and End
.
If you choose End
, Class Wrangler preserves any file name extension in the final file name.
Type ahead selection delay (ticks)
The amount of time, in ticks, Class Wrangler will wait before selecting the file represented by typing on the keyboard.
Use full package name for type ahead
Enable this option to force type ahead selection based on the full package name of the class. For example:
java/awt/Adjustable.class
When you add or open a file using the standard file dialog box, Class Wrangler displays only zip, Jar, and class files in the file list. You control how Class Wrangler identifies the proper files with this group of options in the Preferences dialog.
If you use files created on Mac OS computers, turn off all options. When these options are off, Class Wrangler looks at a file's Mac OS file type to determine whether a file is a zip archive, Jar file, or a class file. Class Wrangler assumes that class files have a file type of 'Clss'
or 'COåk'
. Zip archives have a file type of 'ZIP '
or 'ZipF'
. Jar files have a file type of 'ZIP '
.
If you use files created on other operating systems (such as Windows or UNIX), you will need to turn on one of the options. When you transfer such a file to a Mac OS computer, the file does not have the proper Mac OS file type. Class Wrangler needs some other mechanism it can use to identify that the file is appropriate.
NOTE:
These options do not affect drag and drop operations. To successfully drop a file, it must have the proper Mac OS file type.
Use File Extension when opening files
Will only show files with a .zip, .jar, or .class extension.
TIP:
Use Internet Config to map common Java extensions, such as .zip and .jar to the appropriate Mac OS file types. See "Use Internet Config for File Mappings" for more information.
Use file contents when opening files
Will only show files based on their contents. This option is useful if a zip or Jar file does not have the appropriate extension.
Show All Files
Displays all files in the list regardless of file extension or content. This option overrides the other options, even if they are set.
TIP:
Each of these options are also available to you in the Open dialog box.
The display settings control how Class Wrangler displays a zip/Jar file.
Show full pathname
If the Show full pathname
option is on in the Preferences dialog box, Class Wrangler shows the fully qualified name for every entry in its window, as shown Figure 8.7.
Figure 8.7 The Class Wrangler window with full pathnames
If this option is off, only the name of that entry's package or class file is shown.
Open items collapsed
If the Open items collapsed
option is on in the Preferences dialog box, the program will always open archives with all hierarchical entries collapsed. Click the disclosure triangle to display the contents of a package.
The last two settings tell Class Wrangler what to do at startup and when opening files.
Prompt for file at startup
If the Prompt for file at startup
option is on, Class Wrangler will ask you to specify a file to open when you launch the program.
Verify manifest when opening files
Verifies the manifest information, if present, of a Jar file as Class Wrangler opens the file. Jar files will take longer to open with this option enabled. If a particular entry that has a manifest entry does not verify, Class Wrangler draws it in red.
Class Wrangler allows you to compare two Jar files to determine their differences. You can compare archives on two levels. At the first level, comparison is based on the names and positions of items in the Jar file. The second level compares the Jar files by differences in the contents of each item.
To compare two Jar files, choose File > Compare Files
. The Compare Archives dialog, shown in Figure 8.8, is straight forward to use.
Figure 8.8 Compare archives dialog
Click the Choose
button to pick the files you wish to compare. If you want to compare the files based on differences in the content of each item, click the Compare Using Contents
checkbox. Click Compare
to start the process.
NOTE:
Comparing files requires a lot of RAM. This is especially true if you are comparing large Jar files. It may be necessary to increase the memory partition of Class Wrangler in some cases.
Once the compare process is completed, each archive is displayed in a separate window. Items that are unique to an archive are drawn in green. Items that are in both archives, but are different, are drawn in blue.
TIP:
You will only see items drawn in blue with the Compare Using Contents
option enabled.
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: support@metrowerks.com
Copyright © 1999, Metrowerks Corp. All rights reserved.
Last updated: May 24, 1999
* Chris Magnuson
* John Roseborough